package com.student.Activitys.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.student.Activitys.R;
import com.student.Activitys.adapter.base.BaseRecyleViewAdapter;
import com.student.Activitys.adapter.viewholder.HomeGridViewHolder;
import com.student.Activitys.bean.HomeGridBean;

import java.util.List;


/**
 * 项目名称：智慧校园学生端
 * 类描述：首页 功能栏 adapter
 * 创建人：张飞祥
 * 创建时间：2017/9/30 8:54
 * 修改人：张飞祥
 * 修改时间：2017/9/30 8:54
 * 修改备注：
 */
public class HomeGridAdapter extends BaseRecyleViewAdapter {

    private Context context;
    private List<HomeGridBean> list;

    public HomeGridAdapter(Context context, List<HomeGridBean> list) {
        super(context, list);
        this.context = context;
        this.list = list;
    }


    @Override
    protected int getLayoutItmeResId() {
        return R.layout.item_home_function;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof HomeGridViewHolder) {
            HomeGridViewHolder viewHolder = (HomeGridViewHolder) holder;
            //将数据保存在itemView的Tag中，以便点击时进行获取
            viewHolder.itemView.setTag(position);
            //设置文字
            viewHolder.itemHomeFunctionImg.setImageResource(list.get(position).getHomeIcon());
            //设置标题
            viewHolder.itemHomeFunctionText.setText(list.get(position).getHomeStr());
        }
    }

    @Override
    public RecyclerView.ViewHolder getViewHolder(View view) {
        return new HomeGridViewHolder(view);
    }
}
